<ng-container *ngIf="renderItems.length">
  <ng-container *ngFor="let item of menuItems; let i = index; trackBy: trackByIndex">
    <button
      *ngIf="!item.items || !item.items.length"
      class="lv-operation-menu-item"
      lv-button
      lvType="link"
      lvSize="auto"
      [disabled]="lvDisabled || item.disabled"
      (click)="onClick($event, item)"
    >
      <ng-container *ngIf="itemTemplate; else labelTemplate">
        <ng-container *ngTemplateOutlet="itemTemplate; context: { $implicit: item, index: i }"></ng-container>
      </ng-container>
      <ng-template #labelTemplate>
        <i *ngIf="item.icon" lv-icon="{{ item.icon }}" class="lv-operation-menu-item-icon"></i>
        <span [lv-tooltip]="item.tips">{{ item.label }}</span>
      </ng-template>
    </button>

    <ng-container *ngIf="item.items && item.items.length">
      <a
        class="lv-operation-menu-item-dropdown"
        lv-dropdown
        [lvDropdownMenus]="item.items"
        lvDropdownPanelClass="lv-operation-menu-dropdown-panel"
        [lvDropdownOuterClosable]="lvOuterClosable"
        [lvDropdownDisabled]="lvDisabled"
        (lvDropdownItemClick)="onClick($event)"
      >
        <i *ngIf="item.icon" lv-icon="{{ item.icon }}" class="lv-operation-menu-item-dropdown-icon"></i>
        <span [lv-tooltip]="item.tips">{{ item.label }}</span>
        <i lv-icon="lv-icon-sort-desc" class="lv-operation-menu-text-icon"></i>
      </a>
    </ng-container>
  </ng-container>
</ng-container>

<a
  #dropdownElement
  *ngIf="showDropdownMenu"
  class="lv-operation-menu-dropdown"
  lv-dropdown
  [lvDropdownMenus]="dropdownMenusItems"
  lvDropdownPanelClass="lv-operation-menu-dropdown-panel"
  [lvDropdownOuterClosable]="lvOuterClosable"
  [lvDropdownDisabled]="lvDisabled"
  (lvDropdownItemClick)="onClick($event)"
  (lvDropdownShow)="showDropdown()"
  (lvDropdownHide)="hideDropdown()"
>
  <ng-container *ngIf="menuText; else defaultMoreIcon">
    <span>{{ menuText }}</span>
    <i lv-icon="lv-icon-sort-desc" class="lv-operation-menu-text-icon"></i>
  </ng-container>
  <ng-template #defaultMoreIcon>
    <i lv-icon="lv-icon-more" class="lv-operation-menu-dropdown-more"></i>
  </ng-template>
</a>
